/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controlador.controller;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

import javax.swing.JOptionPane;

/**
 * 
 * @author Emerson
 */
public class ConexaoDB {
	/**
	 * 
	 * @author Emerson
	 */
	class conexaoDB {

		public conexaoDB() {
			// variaveis de conexao com o mysql

			Connection con;
			Statement stmt;
			ResultSet rs;

			// Argumentos do driver de conexão
			String url = "jdbc: myslq://localhost:3306/bancoTeste";
			String user = "root";
			String password = "root";
			String driver = "com.mysql.jdbc.Driver";

			// Public conexaoBDsustentabilidade();
			{
				try {
					Class.forName(driver).newInstance();
					con = DriverManager.getConnection(url, user, password);
					// Cria uma variavel Statement
					stmt = con.createStatement();
				}
				// Captura erro na conexao com o MySql
				catch (Exception e) {
					JOptionPane.showMessageDialog(null,
							"Erro na conexão com o Banco de Dados", "ERRO",
							JOptionPane.ERROR_MESSAGE, null);
				}
			}

		}

	}

}
